Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Add more simple types #1843

Merged
merged 2 commits into from
Mar 6, 2017
Merged

Add more simple types #1843

merged 2 commits into from
Mar 6, 2017

Conversation

andy-hanson
Copy link
Contributor

@andy-hanson andy-hanson commented Dec 11, 2016

PR checklist

  • Addresses an existing issue: #0000
  • New feature, bugfix, or enhancement
    • Includes tests
  • Documentation update (Not needed)

What changes did you make?

Consider the undefined and never types to be simple types. This allows writing undefined[] or never[].
The second commit changes tests to prove that I changed something. Could be removed if you think it's ugly.

[rule-update] array-type now consider undefined and never as simple types, allowing undefined[] and never[]

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @andy-hanson

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, actually, this is a small breaking change because tslint would previously enforce using Array<T> for undefined and never. We should probably put this functionality behind an option and only make the breaking change in v5.0.

@andy-hanson
Copy link
Contributor Author

andy-hanson commented Dec 18, 2016

I wouldn't mind waiting for version 5 to do this.

@ajafff
Copy link
Contributor

ajafff commented Jan 7, 2017

What about ts.SyntaxKind.LiteralType?
That would allow for true[], 1337[], "foo"[].

I just want to add this to the discussion. I don't have an opinion wether they should be considered simple types or not.

@adidahiya
Copy link
Contributor

yeah it's a subjective call about what is considered "simple" here. IMO the examples you just proposed are a little confusing to read (partially because literals in type positions are a more recent addition to the language), so I would prefer writing Array<true>, Array<1337>, Array<"foo">. open to criticism here though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants